package cn.tedu;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) throws SQLException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入英雄名:");
        String name = scanner.nextLine();
        System.out.println("请输入英雄价格:");
        int money = scanner.nextInt();
        Connection coon = DriverManager.getConnection("jdbc:mysql://localhost:3306/empdb?characterEncoding=utf8&serverTimezone=Asia/Shanghai","root","root");
        Statement s = coon.createStatement();
        s.executeUpdate("insert into hero(name,money) values ('"+name+"',"+money+")");
        System.out.println("执行完成!");
        coon.close();
    }
}
